// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Runtime.Serialization;
using Elastic.Transport;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	[JsonConverter(typeof(AppliesToConverter))]
	public enum AppliesTo
	{
		[EnumMember(Value = "typical")]
		Typical,
		[EnumMember(Value = "time")]
		Time,
		[EnumMember(Value = "diff_from_typical")]
		DiffFromTypical,
		[EnumMember(Value = "actual")]
		Actual
	}

	internal sealed class AppliesToConverter : JsonConverter<AppliesTo>
	{
		public override AppliesTo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "typical":
					return AppliesTo.Typical;
				case "time":
					return AppliesTo.Time;
				case "diff_from_typical":
					return AppliesTo.DiffFromTypical;
				case "actual":
					return AppliesTo.Actual;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, AppliesTo value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case AppliesTo.Typical:
					writer.WriteStringValue("typical");
					return;
				case AppliesTo.Time:
					writer.WriteStringValue("time");
					return;
				case AppliesTo.DiffFromTypical:
					writer.WriteStringValue("diff_from_typical");
					return;
				case AppliesTo.Actual:
					writer.WriteStringValue("actual");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(CategorizationStatusConverter))]
	public enum CategorizationStatus
	{
		[EnumMember(Value = "warn")]
		Warn,
		[EnumMember(Value = "ok")]
		Ok
	}

	internal sealed class CategorizationStatusConverter : JsonConverter<CategorizationStatus>
	{
		public override CategorizationStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "warn":
					return CategorizationStatus.Warn;
				case "ok":
					return CategorizationStatus.Ok;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, CategorizationStatus value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case CategorizationStatus.Warn:
					writer.WriteStringValue("warn");
					return;
				case CategorizationStatus.Ok:
					writer.WriteStringValue("ok");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(ChunkingModeConverter))]
	public enum ChunkingMode
	{
		[EnumMember(Value = "off")]
		Off,
		[EnumMember(Value = "manual")]
		Manual,
		[EnumMember(Value = "auto")]
		Auto
	}

	internal sealed class ChunkingModeConverter : JsonConverter<ChunkingMode>
	{
		public override ChunkingMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "off":
					return ChunkingMode.Off;
				case "manual":
					return ChunkingMode.Manual;
				case "auto":
					return ChunkingMode.Auto;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, ChunkingMode value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case ChunkingMode.Off:
					writer.WriteStringValue("off");
					return;
				case ChunkingMode.Manual:
					writer.WriteStringValue("manual");
					return;
				case ChunkingMode.Auto:
					writer.WriteStringValue("auto");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(ConditionOperatorConverter))]
	public enum ConditionOperator
	{
		[EnumMember(Value = "lte")]
		Lte,
		[EnumMember(Value = "lt")]
		Lt,
		[EnumMember(Value = "gte")]
		Gte,
		[EnumMember(Value = "gt")]
		Gt
	}

	internal sealed class ConditionOperatorConverter : JsonConverter<ConditionOperator>
	{
		public override ConditionOperator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "lte":
					return ConditionOperator.Lte;
				case "lt":
					return ConditionOperator.Lt;
				case "gte":
					return ConditionOperator.Gte;
				case "gt":
					return ConditionOperator.Gt;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, ConditionOperator value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case ConditionOperator.Lte:
					writer.WriteStringValue("lte");
					return;
				case ConditionOperator.Lt:
					writer.WriteStringValue("lt");
					return;
				case ConditionOperator.Gte:
					writer.WriteStringValue("gte");
					return;
				case ConditionOperator.Gt:
					writer.WriteStringValue("gt");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(DataframeStateConverter))]
	public enum DataframeState
	{
		[EnumMember(Value = "stopping")]
		Stopping,
		[EnumMember(Value = "stopped")]
		Stopped,
		[EnumMember(Value = "starting")]
		Starting,
		[EnumMember(Value = "started")]
		Started,
		[EnumMember(Value = "failed")]
		Failed
	}

	internal sealed class DataframeStateConverter : JsonConverter<DataframeState>
	{
		public override DataframeState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "stopping":
					return DataframeState.Stopping;
				case "stopped":
					return DataframeState.Stopped;
				case "starting":
					return DataframeState.Starting;
				case "started":
					return DataframeState.Started;
				case "failed":
					return DataframeState.Failed;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, DataframeState value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case DataframeState.Stopping:
					writer.WriteStringValue("stopping");
					return;
				case DataframeState.Stopped:
					writer.WriteStringValue("stopped");
					return;
				case DataframeState.Starting:
					writer.WriteStringValue("starting");
					return;
				case DataframeState.Started:
					writer.WriteStringValue("started");
					return;
				case DataframeState.Failed:
					writer.WriteStringValue("failed");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(DeploymentAllocationStateConverter))]
	public enum DeploymentAllocationState
	{
		[EnumMember(Value = "starting")]
		Starting,
		[EnumMember(Value = "started")]
		Started,
		[EnumMember(Value = "fully_allocated")]
		FullyAllocated
	}

	internal sealed class DeploymentAllocationStateConverter : JsonConverter<DeploymentAllocationState>
	{
		public override DeploymentAllocationState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "starting":
					return DeploymentAllocationState.Starting;
				case "started":
					return DeploymentAllocationState.Started;
				case "fully_allocated":
					return DeploymentAllocationState.FullyAllocated;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, DeploymentAllocationState value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case DeploymentAllocationState.Starting:
					writer.WriteStringValue("starting");
					return;
				case DeploymentAllocationState.Started:
					writer.WriteStringValue("started");
					return;
				case DeploymentAllocationState.FullyAllocated:
					writer.WriteStringValue("fully_allocated");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(DeploymentStateConverter))]
	public enum DeploymentState
	{
		[EnumMember(Value = "stopping")]
		Stopping,
		[EnumMember(Value = "starting")]
		Starting,
		[EnumMember(Value = "started")]
		Started
	}

	internal sealed class DeploymentStateConverter : JsonConverter<DeploymentState>
	{
		public override DeploymentState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "stopping":
					return DeploymentState.Stopping;
				case "starting":
					return DeploymentState.Starting;
				case "started":
					return DeploymentState.Started;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, DeploymentState value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case DeploymentState.Stopping:
					writer.WriteStringValue("stopping");
					return;
				case DeploymentState.Starting:
					writer.WriteStringValue("starting");
					return;
				case DeploymentState.Started:
					writer.WriteStringValue("started");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(ExcludeFrequentConverter))]
	public enum ExcludeFrequent
	{
		[EnumMember(Value = "over")]
		Over,
		[EnumMember(Value = "none")]
		None,
		[EnumMember(Value = "by")]
		By,
		[EnumMember(Value = "all")]
		All
	}

	internal sealed class ExcludeFrequentConverter : JsonConverter<ExcludeFrequent>
	{
		public override ExcludeFrequent Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "over":
					return ExcludeFrequent.Over;
				case "none":
					return ExcludeFrequent.None;
				case "by":
					return ExcludeFrequent.By;
				case "all":
					return ExcludeFrequent.All;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, ExcludeFrequent value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case ExcludeFrequent.Over:
					writer.WriteStringValue("over");
					return;
				case ExcludeFrequent.None:
					writer.WriteStringValue("none");
					return;
				case ExcludeFrequent.By:
					writer.WriteStringValue("by");
					return;
				case ExcludeFrequent.All:
					writer.WriteStringValue("all");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(FilterTypeConverter))]
	public enum FilterType
	{
		[EnumMember(Value = "include")]
		Include,
		[EnumMember(Value = "exclude")]
		Exclude
	}

	internal sealed class FilterTypeConverter : JsonConverter<FilterType>
	{
		public override FilterType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "include":
					return FilterType.Include;
				case "exclude":
					return FilterType.Exclude;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, FilterType value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case FilterType.Include:
					writer.WriteStringValue("include");
					return;
				case FilterType.Exclude:
					writer.WriteStringValue("exclude");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(JobBlockedReasonConverter))]
	public enum JobBlockedReason
	{
		[EnumMember(Value = "revert")]
		Revert,
		[EnumMember(Value = "reset")]
		Reset,
		[EnumMember(Value = "delete")]
		Delete
	}

	internal sealed class JobBlockedReasonConverter : JsonConverter<JobBlockedReason>
	{
		public override JobBlockedReason Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "revert":
					return JobBlockedReason.Revert;
				case "reset":
					return JobBlockedReason.Reset;
				case "delete":
					return JobBlockedReason.Delete;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, JobBlockedReason value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case JobBlockedReason.Revert:
					writer.WriteStringValue("revert");
					return;
				case JobBlockedReason.Reset:
					writer.WriteStringValue("reset");
					return;
				case JobBlockedReason.Delete:
					writer.WriteStringValue("delete");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(JobStateConverter))]
	public enum JobState
	{
		[EnumMember(Value = "opening")]
		Opening,
		[EnumMember(Value = "opened")]
		Opened,
		[EnumMember(Value = "failed")]
		Failed,
		[EnumMember(Value = "closing")]
		Closing,
		[EnumMember(Value = "closed")]
		Closed
	}

	internal sealed class JobStateConverter : JsonConverter<JobState>
	{
		public override JobState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "opening":
					return JobState.Opening;
				case "opened":
					return JobState.Opened;
				case "failed":
					return JobState.Failed;
				case "closing":
					return JobState.Closing;
				case "closed":
					return JobState.Closed;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, JobState value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case JobState.Opening:
					writer.WriteStringValue("opening");
					return;
				case JobState.Opened:
					writer.WriteStringValue("opened");
					return;
				case JobState.Failed:
					writer.WriteStringValue("failed");
					return;
				case JobState.Closing:
					writer.WriteStringValue("closing");
					return;
				case JobState.Closed:
					writer.WriteStringValue("closed");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(MemoryStatusConverter))]
	public enum MemoryStatus
	{
		[EnumMember(Value = "soft_limit")]
		SoftLimit,
		[EnumMember(Value = "ok")]
		Ok,
		[EnumMember(Value = "hard_limit")]
		HardLimit
	}

	internal sealed class MemoryStatusConverter : JsonConverter<MemoryStatus>
	{
		public override MemoryStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "soft_limit":
					return MemoryStatus.SoftLimit;
				case "ok":
					return MemoryStatus.Ok;
				case "hard_limit":
					return MemoryStatus.HardLimit;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, MemoryStatus value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case MemoryStatus.SoftLimit:
					writer.WriteStringValue("soft_limit");
					return;
				case MemoryStatus.Ok:
					writer.WriteStringValue("ok");
					return;
				case MemoryStatus.HardLimit:
					writer.WriteStringValue("hard_limit");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(RoutingStateConverter))]
	public enum RoutingState
	{
		[EnumMember(Value = "stopping")]
		Stopping,
		[EnumMember(Value = "stopped")]
		Stopped,
		[EnumMember(Value = "starting")]
		Starting,
		[EnumMember(Value = "started")]
		Started,
		[EnumMember(Value = "failed")]
		Failed
	}

	internal sealed class RoutingStateConverter : JsonConverter<RoutingState>
	{
		public override RoutingState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "stopping":
					return RoutingState.Stopping;
				case "stopped":
					return RoutingState.Stopped;
				case "starting":
					return RoutingState.Starting;
				case "started":
					return RoutingState.Started;
				case "failed":
					return RoutingState.Failed;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, RoutingState value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case RoutingState.Stopping:
					writer.WriteStringValue("stopping");
					return;
				case RoutingState.Stopped:
					writer.WriteStringValue("stopped");
					return;
				case RoutingState.Starting:
					writer.WriteStringValue("starting");
					return;
				case RoutingState.Started:
					writer.WriteStringValue("started");
					return;
				case RoutingState.Failed:
					writer.WriteStringValue("failed");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(RuleActionConverter))]
	public enum RuleAction
	{
		[EnumMember(Value = "skip_result")]
		SkipResult,
		[EnumMember(Value = "skip_model_update")]
		SkipModelUpdate
	}

	internal sealed class RuleActionConverter : JsonConverter<RuleAction>
	{
		public override RuleAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "skip_result":
					return RuleAction.SkipResult;
				case "skip_model_update":
					return RuleAction.SkipModelUpdate;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, RuleAction value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case RuleAction.SkipResult:
					writer.WriteStringValue("skip_result");
					return;
				case RuleAction.SkipModelUpdate:
					writer.WriteStringValue("skip_model_update");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(TokenizationTruncateConverter))]
	public enum TokenizationTruncate
	{
		[EnumMember(Value = "second")]
		Second,
		[EnumMember(Value = "none")]
		None,
		[EnumMember(Value = "first")]
		First
	}

	internal sealed class TokenizationTruncateConverter : JsonConverter<TokenizationTruncate>
	{
		public override TokenizationTruncate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "second":
					return TokenizationTruncate.Second;
				case "none":
					return TokenizationTruncate.None;
				case "first":
					return TokenizationTruncate.First;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, TokenizationTruncate value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case TokenizationTruncate.Second:
					writer.WriteStringValue("second");
					return;
				case TokenizationTruncate.None:
					writer.WriteStringValue("none");
					return;
				case TokenizationTruncate.First:
					writer.WriteStringValue("first");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(TrainedModelTypeConverter))]
	public enum TrainedModelType
	{
		[EnumMember(Value = "tree_ensemble")]
		TreeEnsemble,
		[EnumMember(Value = "pytorch")]
		Pytorch,
		[EnumMember(Value = "lang_ident")]
		LangIdent
	}

	internal sealed class TrainedModelTypeConverter : JsonConverter<TrainedModelType>
	{
		public override TrainedModelType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "tree_ensemble":
					return TrainedModelType.TreeEnsemble;
				case "pytorch":
					return TrainedModelType.Pytorch;
				case "lang_ident":
					return TrainedModelType.LangIdent;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, TrainedModelType value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case TrainedModelType.TreeEnsemble:
					writer.WriteStringValue("tree_ensemble");
					return;
				case TrainedModelType.Pytorch:
					writer.WriteStringValue("pytorch");
					return;
				case TrainedModelType.LangIdent:
					writer.WriteStringValue("lang_ident");
					return;
			}

			writer.WriteNullValue();
		}
	}
}